export default {
	// 
	install(Vue) {
		// 注册指令// v-timer
		Vue.directive('timer', {

			bind(elem, binding) {
				let { value, arg } = binding;
				let debounceFun = debounce(value, arg);
				elem.onkeyup = debounceFun;
			}
		});
		// 防抖
		function debounce(fun, ms) {
			let timer = null;
			ms = ms || 800;
			return function () {
				if (timer) clearTimeout(timer);
				timer = setTimeout(() => {
					fun.apply(this);
				}, ms)
			}
		}
	}
}